﻿#region Using Directives

using System;
using System.Collections.Generic;
using System.IO;

#endregion Using Directives


namespace Kongo.Tags
{
    internal class CycleTag : Tag
    {
        #region Fields

        private int index;
        private List<Variable> variables;

        #endregion Fields


        #region Methods

        public override void Render(Context context, TextWriter output)
        {
            if (index >= variables.Count)
                index = 0;

            variables[index].Render(context, output);
            index++;
        }

        #endregion Methods


        #region Constructors

        public CycleTag(string[] args)
        {
            this.variables = new List<Variable>();
            for (int i = 1; i < args.Length; i++)
                variables.Add(new Variable(args[i]));
        }

        #endregion Constructors


        #region Types

        public class CycleTagCreator : ITagCreator
        {
            #region Methods

            public Tag Create(string[] args)
            {
                return new CycleTag(args);
            }

            #endregion Methods
        }

        #endregion Types
    }
}
